<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/mytag.jspf"%>

<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<title>商品管理</title>
<script type="text/javascript">
	$("#grid").jqGrid({
		pager:"#pager",
		url:"management/mdse/page",
		datatype: "json",  //请求的数据类型
	   	colNames:["商品编号","商品名称","商品类别","会员价","非会员价","操作"],
	   	colModel:[
	   		{name:"no"},
	   		{name:"name"},
	   		{name:"categoryName"},
	   		{name:"vipPrice"},
	   		{name:"noVipPrice"},
	   		{name:"ctrl",width:200,formatter:function(cellvalue, options, row){
	   			var btns = "<div class='am-btn-group am-btn-group-xs'>";
	   			btns+="<a href='management/mdse/edit/"+row.mdseId+"' class='am-btn am-btn-default' title='修改'><span class='am-icon-edit'></span> 修改</a>";
	   			btns+="<a href='management/mdse/store/index/"+row.mdseId+"' class='am-btn am-btn-default' title='库存'><span class='am-icon-bars'></span> 库存</a>";
	   			btns+="<button type='button' class='am-btn am-btn-default' title='删除' onclick='delRow(\""+row.mdseId+"\")'><span class='am-icon-trash'></span> 删除</button>";
	   			btns+="</div>";
	   			return btns;
	   		}},
	   	]
	});
	
	function delRow(id){
		if (id == "") {
			layer.msg("请选择删除项！！");
			return;
		}
		layer.confirm('是否删除？', function(index) {
			var url = "management/mdse/delete/"+id;
			$.ajax({
				type : 'POST',
				url : url,
				dataType : 'json',
				success : function(data) {
					layer.msg(data.msg);
					if (data.success) {
						$("#grid").jqGrid().trigger("reloadGrid"); //重新载入 
					}
				}
			});
		});
	}
	$(function(){ 
	    $("#searchBtn").click(function(){
	        $("#grid").jqGrid('setGridParam',{ 
	            postData:$("#queryForm").serializeJson(), //发送数据
	            page:1
	        }).trigger("reloadGrid"); //重新载入 
	    }); 
	});
</script>
</head>

<body>
	<ol class="am-breadcrumb am-breadcrumb-slash am-padding" style="margin-bottom: 0px;">
		<li><a href="management/index">首页</a></li>
		<li class="am-active">商品管理</li>
	</ol>
	<div class="am-g">
		<div class="am-u-md-8">
			<div class="am-btn-toolbar">
				<div class="am-btn-group am-btn-group-sm">
					<a href="management/mdse/add" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</a>
				</div>
			</div>
		</div>
		<form id="queryForm">
		<div class="am-u-md-4">
			<div class="am-input-group am-input-group-sm">
				<input type="text" name="name" class="am-form-field" placeholder="请输入商品名称查询"><span class="am-input-group-btn"><button class="am-btn am-btn-default" type="button" id="searchBtn">搜索</button></span>
			</div>
		</div>
		</form>
	</div>
	<div class="am-g am-padding-vertical">
		<div class="am-u-md-12"><table id="grid"></table><div id="pager"></div></div>
	</div>
</body>
</html>
